#version 320 es
#ifdef GL_ES
	precision highp float;
#endif
in vec3 iVertex;
in vec3 iNormal;
in vec2 iTexcoord;

out vec3 ioNormal;// model world normal
out vec3 ioViewVector;
out vec2 ioTexcoord;

out vec3 position;

uniform mat4 uM;
uniform mat4 uV;
uniform mat4 uMVInvTr;
uniform mat4 uMVP;

void main()
{
	vec4 worldPos = uM * vec4(iVertex, 1.0);
	ioNormal = vec3(uMVInvTr * vec4(iNormal, 0.0));
	ioViewVector = -vec3(uV * worldPos);// ViewVector(from vertex pointing to camera)

	position = worldPos.xyz;
	ioTexcoord = iTexcoord;
	gl_Position =  uMVP * vec4(iVertex, 1.0);
}